﻿using System;

namespace GLog
{
    public class ConsoleLog : Log
    {
        public ConsoleLog(ILog postLog = null, LogLevel displayLevel = LogLevel.Error|LogLevel.Message|LogLevel.Warning)
            : base(postLog, displayLevel: displayLevel)
        {

        }
        public override void Initial()
        {
            Console.WriteLine("Log Started.");
        }

        public override void WriteLog()
        {
            Console.WriteLine("Log Finished.");
        }

        internal override void LogMessage(string info, LogLevel level)
        {
            switch (level)
            {
                case LogLevel.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Error: {0}", info);
                    break;
                case LogLevel.Message:
                    Console.ResetColor();
                    Console.WriteLine("Message: {0}", info);
                    break;
                case LogLevel.Warning:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Warning: {0}", info);
                    break;
                default:
                    throw new InvalidOperationException("Unrecognized log level.");
            }
            Console.ResetColor();
        }

        protected override void OutputHeader(string message)
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine(message);
            Console.ResetColor();
        }
    }
}
